﻿using UnityEngine;
using UnityEngine.UI;

namespace DiverseStudents.UI
{
    internal static partial class UICreate
    {
        public static GameObject Mask(bool _show = true)
        {
            if (uiRoot != null)
            {
                var g1 = GameObject.Instantiate(uiRoot.transform.Find("Mask").gameObject);
                if (g1 != null)
                {
                    g1.name = "Mod_Mask";
                    g1.SetActive(_show);
                    return g1;
                }

            }
            return CreateErrorMask(_show);
        }


        private static GameObject CreateErrorMask(bool _show = true)
        {
            GameObject gameObject = new GameObject("Mod_ErrorMask", typeof(Mask));
            var img = gameObject.AddComponent<Image>();
            if(img != null)
            {
               img.color = Color.black;
            }
            gameObject.SetActive(_show);
            return gameObject;

        }
    }
}
